//
//  TYZPageScrollView.m
//  AVfoundationDemo
//
//  Created by TangBin on 2019/8/14.
//  Copyright © 2019 TangBin. All rights reserved.
//

#import "TYZPageScrollView.h"
#import <objc/runtime.h>

@interface TYZPageScrollView () <UIGestureRecognizerDelegate>

@end

@implementation TYZPageScrollView

- (BOOL)panBack:(UIGestureRecognizer *)gestureRecognizer
{
    int locationX = 0.15 * kScreenWidth;
    if (gestureRecognizer == self.panGestureRecognizer)
    {
        UIPanGestureRecognizer *pan = (UIPanGestureRecognizer *)gestureRecognizer;
        CGPoint point = [pan translationInView:self];
        UIGestureRecognizerState state = gestureRecognizer.state;
        if (state == UIGestureRecognizerStateBegan || state == UIGestureRecognizerStatePossible)
        {
            CGPoint location = [gestureRecognizer locationInView:self];
            int tmp1 = location.x;
            int tmp2 = kScreenWidth;
            NSInteger XX = tmp1 % tmp2;
            if (point.x > 0 && XX < locationX)
            {
                return YES;
            }
        }
    }
    return NO;
}

#pragma mark - UIGestureRecognizerDelegate
// 是否支持多时候触发，返回yes 则可以多个手势手势以前触发方法；NO则为互斥
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    if ([self panBack:gestureRecognizer])
    {
        return YES;
    }
    return NO;
}

// 开始进行手势识别时调用的方法，返回NO则结束，不再触发手势
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
    if ([self panBack:gestureRecognizer])
    {
        return NO;
    }
    return YES;
}


@end





































